/**  
* @Title: SocketServiceLoader.java  
* @Package socket  
* @Description: TODO(用一句话描述该文件做什么)  
* @author Mr.zhao  
* @date 2018年7月24日  
* @version V1.0  
*/
package com.shuodao.cokeps.socket;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * @author Mr.zhao
 * @date 2018年7月24日
 *
 */
public class SocketServiceLoader implements ServletContextListener {

	private Thread thread;

	// 线程销毁
	public void contextDestroyed(ServletContextEvent sce) {
		if (thread != null && thread.isInterrupted()) {
			thread.interrupt();
		}
	}

	// 线程启动
	public void contextInitialized(ServletContextEvent sce) {
		if (thread == null) {
			SocketOperate socketOperate = new SocketOperate();
			thread = new Thread(socketOperate);
			thread.start();
		}
	}
}
